package agent

import (
	"cloud_worm/util/uweb/ucron"
)

// ScanWolAgentInstallJob 扫描安装wolagent的任务
type ScanWolAgentInstallJob struct {
	Name 		string
}

// whiteRoomDeal 白名单机房处理
// bool		true		表示是白名单，不用处理
func (s ScanWolAgentInstallJob) whiteRoomDeal(name string) (*NoWolAgentRoom, bool) {
	//_, exist := whiteRooms[name]
	//if exist != true {
	//	return nil, false
	//}
	//
	//room := &NoWolAgentRoom{
	//	RoomName: name,
	//	ErrorInfo: whiteRooms[name],
	//}
	return nil, true
}

// Run 任务运行
func (s ScanWolAgentInstallJob) Run() {
	//recordId, err := crontask.CronJobBegin(s)

	// TODO: xxx

	// 报告发送出来
	// TODO: xxxxxx

	//crontask.CronJobEnd(recordId, s, strings.Join(msgs, ";"))
	return
}

// ScanResult 扫描的结果
type ScanResult struct {
	MapRooms		map[string]*NoWolAgentRoom		`json:"map_rooms"`
} 

// NoWolAgentRoom 未安装
type NoWolAgentRoom struct {
	RoomName 		string					`json:"room_name"`
	WolAgentCnt		int						`json:"wol_agent_cnt"`
	ErrorInfo		string					`json:"error_info"`

	NoWolAgentCnt 	int						`json:"no_wol_agent_cnt"`
	NoWolAgentList	[]NoWolAgentMachine		`json:"no_wol_agent_list"`
}

// NoWolAgentMachine 未安装agent machine的实例
type NoWolAgentMachine struct {
	IP 			string						`json:"ip"`
	ErrorInfo 	string						`json:"error_info"`
	OSRelease	string						`json:"os_release"`		// 系统类型
	DevStatus 	string						`json:"dev_status"`
	Ping 		bool						`json:"ping"`
	WuKongRet 	string						`json:"wu_kong_ret"`
}

// init initial Job
func init()  {
	ucron.RegisterCronJob(&ScanWolAgentInstallJob{Name: "scan_wolagent_install"})
}